From 3432dff2e0c21fa693d41e3950ee19624c03f58c Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Sun, 18 Nov 2001 23:33:21 +0000 Subject: [PATCH] Make a NO_WINDOW widget, as it should have been since the beginning, but Sun Nov 18 18:18:11 2001 Owen Taylor * gtk/gtkfixed.c: Make a NO_WINDOW widget, as it should have been since the beginning, but as special hack, allow clearing the NO_WINDOW flag to get a window widget. --- ChangeLog | 6 ++++ ChangeLog.pre-2-0 | 6 ++++ ChangeLog.pre-2-10 | 6 ++++ ChangeLog.pre-2-2 | 6 ++++ ChangeLog.pre-2-4 | 6 ++++ ChangeLog.pre-2-6 | 6 ++++ ChangeLog.pre-2-8 | 6 ++++ docs/Changes-2.0.txt | 10 +++++- gtk/gtkfixed.c | 72 +++++++++++++++++++++++++++----------------- 9 files changed, 95 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index 85e4f40dcd..c5fd2f0f1c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sun Nov 18 18:18:11 2001 Owen Taylor + + * gtk/gtkfixed.c: Make a NO_WINDOW widget, as it should + have been since the beginning, but as special hack, + allow clearing the NO_WINDOW flag to get a window widget. + Sun Nov 18 22:01:36 Kristian Rietveld * gtk/gtktreestore.c: return TRUE when value changed, so diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 85e4f40dcd..c5fd2f0f1c 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,9 @@ +Sun Nov 18 18:18:11 2001 Owen Taylor + + * gtk/gtkfixed.c: Make a NO_WINDOW widget, as it should + have been since the beginning, but as special hack, + allow clearing the NO_WINDOW flag to get a window widget. + Sun Nov 18 22:01:36 Kristian Rietveld * gtk/gtktreestore.c: return TRUE when value changed, so diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 85e4f40dcd..c5fd2f0f1c 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +Sun Nov 18 18:18:11 2001 Owen Taylor + + * gtk/gtkfixed.c: Make a NO_WINDOW widget, as it should + have been since the beginning, but as special hack, + allow clearing the NO_WINDOW flag to get a window widget. + Sun Nov 18 22:01:36 Kristian Rietveld * gtk/gtktreestore.c: return TRUE when value changed, so diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 85e4f40dcd..c5fd2f0f1c 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,9 @@ +Sun Nov 18 18:18:11 2001 Owen Taylor + + * gtk/gtkfixed.c: Make a NO_WINDOW widget, as it should + have been since the beginning, but as special hack, + allow clearing the NO_WINDOW flag to get a window widget. + Sun Nov 18 22:01:36 Kristian Rietveld * gtk/gtktreestore.c: return TRUE when value changed, so diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 85e4f40dcd..c5fd2f0f1c 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,9 @@ +Sun Nov 18 18:18:11 2001 Owen Taylor + + * gtk/gtkfixed.c: Make a NO_WINDOW widget, as it should + have been since the beginning, but as special hack, + allow clearing the NO_WINDOW flag to get a window widget. + Sun Nov 18 22:01:36 Kristian Rietveld * gtk/gtktreestore.c: return TRUE when value changed, so diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 85e4f40dcd..c5fd2f0f1c 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,9 @@ +Sun Nov 18 18:18:11 2001 Owen Taylor + + * gtk/gtkfixed.c: Make a NO_WINDOW widget, as it should + have been since the beginning, but as special hack, + allow clearing the NO_WINDOW flag to get a window widget. + Sun Nov 18 22:01:36 Kristian Rietveld * gtk/gtktreestore.c: return TRUE when value changed, so diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 85e4f40dcd..c5fd2f0f1c 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,9 @@ +Sun Nov 18 18:18:11 2001 Owen Taylor + + * gtk/gtkfixed.c: Make a NO_WINDOW widget, as it should + have been since the beginning, but as special hack, + allow clearing the NO_WINDOW flag to get a window widget. + Sun Nov 18 22:01:36 Kristian Rietveld * gtk/gtktreestore.c: return TRUE when value changed, so diff --git a/docs/Changes-2.0.txt b/docs/Changes-2.0.txt index 6e4222577e..1c8e8cfddd 100644 --- a/docs/Changes-2.0.txt +++ b/docs/Changes-2.0.txt @@ -528,7 +528,15 @@ Incompatible Changes from GTK+-1.2 to GTK+-2.0: you must make sure you call gtk_container_propagate_expose() correctly, as you must for any NO_WINDOW widgets. + GtkFixed is a little special; it is now created by default as + a NO_WINDOW widget, but if you do + + GTK_WIDGET_UNSET_FLAGS (fixed, GTK_WIDGET_NO_WINDOW) + + after creating a fixed widget, it will create a window and + handle it properly. + * GtkLayout no longer has the xoffset, yoffset fields, which used to store the difference between world and window coordinates for layout->bin_window. These coordinate systems are now always - the same. \ No newline at end of file + the same. diff --git a/gtk/gtkfixed.c b/gtk/gtkfixed.c index 2295d286f6..8f5dd6d4d0 100644 --- a/gtk/gtkfixed.c +++ b/gtk/gtkfixed.c @@ -144,7 +144,7 @@ gtk_fixed_child_type (GtkContainer *container) static void gtk_fixed_init (GtkFixed *fixed) { - GTK_WIDGET_UNSET_FLAGS (fixed, GTK_NO_WINDOW); + GTK_WIDGET_SET_FLAGS (fixed, GTK_NO_WINDOW); fixed->children = NULL; } @@ -311,27 +311,32 @@ gtk_fixed_realize (GtkWidget *widget) g_return_if_fail (GTK_IS_FIXED (widget)); - GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); - - attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; - attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); - attributes.colormap = gtk_widget_get_colormap (widget); - attributes.event_mask = gtk_widget_get_events (widget); - attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK; - - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, - attributes_mask); - gdk_window_set_user_data (widget->window, widget); - - widget->style = gtk_style_attach (widget->style, widget->window); - gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); + if (GTK_WIDGET_NO_WINDOW (widget)) + GTK_WIDGET_CLASS (parent_class)->realize (widget); + else + { + GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); + + attributes.window_type = GDK_WINDOW_CHILD; + attributes.x = widget->allocation.x; + attributes.y = widget->allocation.y; + attributes.width = widget->allocation.width; + attributes.height = widget->allocation.height; + attributes.wclass = GDK_INPUT_OUTPUT; + attributes.visual = gtk_widget_get_visual (widget); + attributes.colormap = gtk_widget_get_colormap (widget); + attributes.event_mask = gtk_widget_get_events (widget); + attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK; + + attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; + + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, + attributes_mask); + gdk_window_set_user_data (widget->window, widget); + + widget->style = gtk_style_attach (widget->style, widget->window); + gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); + } } static void @@ -390,13 +395,17 @@ gtk_fixed_size_allocate (GtkWidget *widget, fixed = GTK_FIXED (widget); widget->allocation = *allocation; - if (GTK_WIDGET_REALIZED (widget)) - gdk_window_move_resize (widget->window, - allocation->x, - allocation->y, - allocation->width, - allocation->height); + if (!GTK_WIDGET_NO_WINDOW (widget)) + { + if (GTK_WIDGET_REALIZED (widget)) + gdk_window_move_resize (widget->window, + allocation->x, + allocation->y, + allocation->width, + allocation->height); + } + border_width = GTK_CONTAINER (fixed)->border_width; children = fixed->children; @@ -410,6 +419,13 @@ gtk_fixed_size_allocate (GtkWidget *widget, gtk_widget_get_child_requisition (child->widget, &child_requisition); child_allocation.x = child->x + border_width; child_allocation.y = child->y + border_width; + + if (GTK_WIDGET_NO_WINDOW (widget)) + { + child_allocation.x += widget->allocation.x; + child_allocation.y += widget->allocation.y; + } + child_allocation.width = child_requisition.width; child_allocation.height = child_requisition.height; gtk_widget_size_allocate (child->widget, &child_allocation); -- 2.30.2